package com.mairuide.base_dict.special_addr.controller;

import com.mairuide._frame.base.BaseController;
import com.mairuide.base_dict.special_addr.dto.SpecialAddrDto;
import com.mairuide.base_dict.special_addr.pojo.SpecialAddr;
import com.mairuide.base_dict.special_addr.service.SpecialAddrService;
import com.mairuide.entity.PageResult;
import com.mairuide.entity.Result;
import com.mairuide.entity.StatusCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Description
 * @auther 刘中华
 * @create 2019-06-04 15:02
 */
@RequestMapping("/special_addr")
@Controller
public class SpecialAddrController extends BaseController {
    @Autowired
    SpecialAddrService specialAddrService;

    @RequestMapping("index")
    public String index(){
        return "/base_dict/special_addr/special_addr";
    }
    @RequestMapping("openSpecialAddrDialog")
    public String openSpecialAddrDialog(){
        return "/base_dict/special_addr/openSpecialAddrDialog";
    }

    //查询特殊地点
    @RequestMapping("findOneById")
    @ResponseBody
    public Result findOneById(Integer id){
        SpecialAddr specialAddr = specialAddrService.findOnebyId(id);
        return new Result(true, StatusCode.OK,"保存成功" ,specialAddr);
    }

    //保存特殊地点
    @RequestMapping("save")
    @ResponseBody
    public Result save(SpecialAddr sd){
        specialAddrService.save(sd);
        return new Result(true, StatusCode.OK,"保存成功" );
    }
    //删除特殊地点
    @RequestMapping("del")
    @ResponseBody
    public Result del(Integer id){
        specialAddrService.del(id);
        return new Result(true, StatusCode.OK,"删除成功" );
    }
    //分页查询特殊地点
    @RequestMapping("page")
    @ResponseBody
    public PageResult query(SpecialAddrDto dto){
        PageResult page = specialAddrService.findByPage(dto);
        return page;
    }
}
